//
// Created by Administrator on 2021/9/7.
//
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <climits>

using namespace std;
class Solution {
public:
    int balancedStringSplit(string s) {
        int cal = 0,ans=0;
        for(char &x:s){
            if (x=='L')
                ++cal;
            else
                --cal;
            if(cal==0)
                ++ans;
        }
        return ans;
    }
};
int main() {
    Solution solution;
    cout << solution.balancedStringSplit("RLRRLLRLRL")<<endl;
    cout << solution.balancedStringSplit("RLLLLRRRLR")<<endl;
    cout << solution.balancedStringSplit("LLLLRRRR")<<endl;
    cout << solution.balancedStringSplit( "RLRRRLLRLL")<<endl;
    return 0;
}
